import React, { Component } from 'react'
import { FormattedMessage } from 'react-intl'
import { CommonHeader } from '../header'
import { FooterBar } from '../footer'
import { helper, myFetch, config } from 'component/utils'
import { GuadanDetailTop, PositionOrderDirect, PositionOrderOco } from './'
import { LimitStopAll } from 'component/trade'
import Reflux from 'reflux'
import { PriceAction } from '../../actions'
import { PriceStore } from '../../stores'

export default class PositionModifyOrder extends Component {
  
  constructor(props) {
    super(props)
    this.state = {
      status: 0,
      data: []
    }
  }
  onRelateorder = () => {
    const options = {
       method: 'POST',
       body: JSON.stringify({
        ORDN: this.props.location.query.orderno
      })
    }
    myFetch(`${config.rootApi}/mRelateorder`, options, true)
     .then((rs) => {
      console.log(rs, rs)
        if (rs && rs.statusCode == 0) {
          let data = rs.dataInfoRelateOrder.dataListRelateOrders
          console.log(data)
          this.setState({
            status: rs.orderFormCls,
            data: data
          })
      }
     })
  }
  componentDidMount() {
    this.onRelateorder()
  }
  render() {
    return (
      <div>
        <CommonHeader
          title={
            <span>
              <FormattedMessage id="post"/>
              <FormattedMessage id="details"/>
            </span>
          }
        />
        <GuadanDetailTop data={this.state.data[0]}/>
        <div className="-background rt-height22"></div>
        <div className="cm-scrollable-container rt-padding-24">
        {
          this.state.status == 0 ? <PositionOrderDirect data={this.state.data}/> : 
          this.state.status == 1 ? <PositionOrderDirect data={this.state.data}/> :
          <PositionOrderOco data={this.state.data}/>
        }
          
        </div>
        <FooterBar activeIndex={1}/>
      </div>
      )
  }
}